#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar csl,cs2,num1,num2;
uchar code table[]={0,1};
sbit qdg = P3^4;
sbit xdg = P3^5;
sbit in1 = P1^0;
sbit in2 = P1^1;
sbit in3 = P1^2;
sbit in4 = P1^3;
sbit ena = P1^4;
sbit enb = P1^5;

void delay(int z)
{
 unsigned int x,y;
 for(x=z;x>0;x--)
    for(y=z;y>0;y--);
}
void init()
{
 TMOD = 0x11;
 TH0 = (65536-500)/250;
 TL0 = (65536-500)%256;
 ET0 = 1;
 TR0 = 1;
 EA = 1;
}

void main()
{
 init();
 while(1);
 {
  if(qdg == 1)
  {
     ena = 1;
	 enb = 1;
	 in2 = 0;
	 in4 = 0;
  }
  else
  {
     ena = 0;
	 delay(1000);
	 ena = 1;
  }
  if(xdg == 0)
    {
	 in2 = 1;
	 in4 = 1;
	 delay(1000);
	 ena=0;
	 delay(1000);
	}
 }
}

void tiner0() interrupt 1
{
    TH0=(65536-500)/256;
	TL0=(65536-500)%256;
	csl++;
	if (csl==10)
	{
	csl=0;
	  num1++;
	if (num1==3)
	num1=0;
	in1 = table[num1];
	num2++;
	if(num2==3)
	num2=0;
	in3 = table[num2];
	}
}